$package('jeecg.TostPjTeammemberinfo');

$(document).ready(function (){
	$("#container").ready(function (){
		$.ajax({
			url:"dataList.do",
			dataType:'json',
			success:function (result){
				var name=new Array();
				var time=new Array();
				for(var i=0;i<result.total;i++){
					name[i]=result.data[i].hrName;
					//time[i]="["+result.data[i].ptmEntertime+","+result.data[i].ptmLeavetime+"]";
					time[i]=-9.4;
				}
				fun(name,time);
			}
		});
	});
});

	function fun(name,time){
		
		alert(time[0]);
		$('#container').highcharts({
		
		    chart: {
		        type: 'columnrange',
		        inverted: true
		    },
		    
		    title: {
		        text: 'Temperature variation by month'
		    },
		    
			subtitle: {
		        text: 'Observed in Vik i Sogn, Norway, 2009'
		    },
		
		    xAxis: {
		        categories: name
		    },
		    
		    yAxis: {
		        title: {
		            text: '人员服务天数图'
		        },
		        allowDecimals:false,
		        min:0,
		        //categories:[2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023],
		        series : [{
                    name : 'Temperature',
                    data : [7.0],
                    color : '#F33'
                }]
		        
		    },
		
		    tooltip: {
		        valueSuffix: ''
		    },
		    
		    plotOptions: {
		        columnrange: {
		        	dataLabels: {
		        		enabled: true,
		        		formatter: function () {
		        			return this.y;
		        		}
		        	}
		        }
		    },
		    
		    legend: {
		        enabled: false
		    },
		
		    series: [{
		        name: '服务月份',
		        data: [
					[-9.7,9.4],
					time
				]
		    }]
		});
	};


jeecg.TostPjTeammemberinfo = function(){
	var _box = null;
	var _this = {
		toList:function(parentId){
				_box.form.search.resetForm();
				if(parentId){
					$('#search_parentId').val(parentId);
					$('#btnback').linkbutton('enable');
					_box.grid.datagrid('hideColumn','childMenus');
				}else{
					$('#btnback').linkbutton('disable');
					$('#btnback').linkbutton('disable');
					_box.grid.datagrid('showColumn','childMenus');
				}
				_box.handler.refresh();
		},
		//设置默认按钮数据
		addDefBtns:function(){
			var defaultBtns= [
				{"btnName":"添加","menuid":2,"actionUrls":"save.do","btnType":"add"},
				{"btnName":"修改","menuid":2,"actionUrls":"getId.do|save.do","btnType":"edit"},
				{"btnName":"删除","menuid":2,"actionUrls":"delete.do","btnType":"remove"}
			];
			var tbline = $(".tb-line:visible");
			var btnType = $("input[name='btnType']",tbline);
			$.each(defaultBtns,function(i,btn){
				var isExists = false;
				//判断按钮类型是否存在
				if(btnType.length > 0){
					for(var i =0; i < btnType.length; i++){
						if(btnType.eq(i).val() == btn.btnType){
							isExists = true;
							break;
						}
					}
				}
				if(!isExists){
					_this.addLine(btn);
				}
			});
		},
		addLine: function(data){
			var table = $("#btn-tb");
			var	html = "<tr class='tb-line'>";
			html+=	   "	<td align='center'><span  class='newFlag red'>*</span></td>";
			html+=	   "	<td><input name=\"btnName\" class=\"easyui-validatebox text-name\" style=\"width:100%\" data-options=\"required:true\"></td>";
			html+=	   "	<td><input name=\"btnType\" class=\"easyui-validatebox text-name\" style=\"width:100%\" data-options=\"required:true\"></td>";
			html+=	   "	<td><input name=\"actionUrls\" class=\"easyui-validatebox text-desc\" style=\"width:100%\"  ></td>";
			html+=	   "	<td align='center'><a class=\"easyui-linkbutton remove-btn\"  iconCls=\"icon-remove\" plain=\"true\"></a>";
			html+=	   "	<input class=\"hidden\" name=\"btnId\">";
			html+=	   "	<input class=\"hidden\" name=\"deleteFlag\">";
			html+=	   "	</td>";
			html+=	   "</tr>";
			var line = $(html);
			//版定删除按钮事件
			$(".remove-btn",line).click(function(){
				jeecg.confirm('Confirm','Are you sure you want to delete record?',function(r){
					if(r){
						_this.delLine(line);
					}
				})
			});
			if(data){
				if(data.id){
					$(".newFlag",line).html(''); //清空新增标记
				}
				$("input[name='btnId']",line).val(data.id);
				$("input[name='btnName']",line).val(data.btnName);
				$("input[name='btnType']",line).val(data.btnType);
				$("input[name='actionUrls']",line).val(data.actionUrls);
			}
			$.parser.parse(line);//解析esayui标签
			table.append(line);
			
		},
		//删除全部
		delAllLine:function(b){
			if(b){
				$(".tb-line").remove();
			}else{
				$(".tb-line").each(function(i,line){
					_this.delLine($(line));
				});
			}
		},
		//删除单行
		delLine:function(line){
			if(line){
				var btnId = $("input[name='btnId']",line).val();
				if(btnId){
					$("input[name='deleteFlag']",line).val(1); //设置删除状态
					line.fadeOut();
				}else{
					line.fadeOut("fast",function(){
						 $(this).remove();
					});
				}
			}
		},
		config:{
  			action:{
  				save:'', //新增&修改 保存Action  
  				getId:'',//编辑获取的Action
  				delele:''//删除数据的Action
  			},
  			event:{
  				add : function(){
  					_this.delAllLine(true);//清空已有的数据
  					_box.handler.add();//调用add方法
					var parentId =$('#search_parentId').val();
					if(parentId){
						$("#edit_parentId").val(parentId);
					}
				},
				edit:function(){
					_this.delAllLine(true);
					_box.handler.edit(function(result){
						if(result!=null && typeof(result.data.btns)!= "undefined"){
						$.each(result.data.btns,function(i,btn){
							_this.addLine(btn);
						});
						}
					});
				}
  			},
  			dataGrid:{
  				title:'Menu List',
	   			url:'dataList.do',
	   			columns:[[
					{field:'id',title:'ID',width:120,sortable:true},				
					{field:'pjId',title:'PJ_ID',width:120,sortable:true},				
					{field:'hrId',title:'HR_ID',width:120,sortable:true},				
					{field:'hdpId',title:'HDP_ID',width:120,sortable:true},				
					{field:'hdpName',title:'HDP_NAME',width:120,sortable:true},				
					{field:'hrName',title:'HR_NAME',width:120,sortable:true},				
					{field:'hpoId',title:'HPO_ID',width:120,sortable:true},				
					{field:'hpoName',title:'HPO_NAME',width:120,sortable:true},				
					{field:'ptmEntertime',title:'PTM_ENTERTIME',width:120,sortable:true},				
					{field:'ptmLeavetime',title:'PTM_LEAVETIME',width:120,sortable:true},				
					{field:'ptmStatus',title:'PTM_STATUS',width:120,sortable:true},				
					{field:'ptmServerday',title:'PTM_SERVERDAY',width:120,sortable:true},				
					{field:'ptmMonth',title:'PTM_MONTH',width:120,sortable:true},				
					{field:'ptmNumber',title:'PTM_NUMBER',width:120,sortable:true},				
					{field:'createtime',title:'CREATETIME',width:120,sortable:true},				
					{field:'person',title:'PERSON',width:120,sortable:true}				
				]],
				toolbar:[
					{id:'btnadd',text:'添加',btnType:'add'},
					{id:'btnedit',text:'修改',btnType:'edit'},
					{id:'btndelete',text:'删除',btnType:'remove'},
					{
						id:'btnback',
						text:'back',
						disabled: true,
						iconCls:'icon-back',
						handler:function(){
							_this.toList();
						}
					}
				]
			}
		},
		init:function(){
			_box = new YDataGrid(_this.config); 
			_box.init();
			$('#addLine_btn').click(_this.addLine);
			$('#addDefLine_btn').click(_this.addDefBtns);
			$('#delAllLine_btn').click(function(){
				jeecg.confirm('Confirm','Are you sure you want to delete record?',function(r){
					_this.delAllLine(false);
				});
			});
			
		}
	}
	return _this;
}();

$(function(){
	jeecg.TostPjTeammemberinfo.init();
});